/*
 * Vector.h
 *
 *  Created on: 2014年2月27日
 *      Author: Administrator
 */

#ifndef VECTOR_H_
#define VECTOR_H_

namespace VECTOR {

class Vector {
private:
	double x;
	double y;
	double mag; /** 向量长度*/
	double ang; /** 向量方向*/
	char mode;
	//private methods for setting values
	void set_mag();
	void set_ang();
	void set_x();
	void set_y();
public:
	Vector();
	Vector(double n1,double n2,char form='r');
	void set(double n1,double n2,char form='r');
	virtual ~Vector();
	double xval()const{return x;}
	double yval()const{return y;}
    double magval()const{return mag;}
    double angval()const{return ang;}
    void poloar_mode();
    void rect_mode();
    /**
     * operator overloading
     * 操作符重载
     */
    Vector operator+(const Vector &b)const;
    Vector operator-(const Vector &b)const;
    Vector operator-()const;
    Vector operator*(double n)const;
    /**
     * friends 友元
     */
    friend Vector operator*(double n,const Vector &a);
    friend std::ostream & operator<<(std::ostream & os,const Vector &v);
};

} /* namespace VECTOR */

#endif /* VECTOR_H_ */
